let el = globalThis.manager.aside.el
let childs = globalThis.manager.aside.childs
for (let index = 0; index < childs.length; index++) {
  const element = childs[index];
  element.setAttribute('data-id', index + '')
}
//#region 点击事件
el.addEventListener('click', (e: any) => {
  let element = e.toElement
  let tagName = element.tagName.toLocaleLowerCase()
  //只有当不是li和ul时做处理
  if (tagName !== 'ul') {
    if (tagName !== 'li') {
      for (let index = 0; index < e.path.length; index++) {
        if (e.path[index].tagName.toLocaleLowerCase() === 'li') {
          element = e.path[index]
          break
        }
      }
    }
  } else {
    //点击到ul直接返回
    return
  }
  globalThis.manager.aside.index = +element.getAttribute('data-id')
})
//#endregion


//#region 上下移动事件
document.body.addEventListener('keyup', (e) => {
  if(globalThis.manager.focus === 1){
    switch (e.key) {
      case 'ArrowDown':
        if (globalThis.manager.aside.index === childs.length - 1) {
          globalThis.manager.aside.index = 0
        } else {
          globalThis.manager.aside.index += 1
        }
        break;
      case 'ArrowUp':
        if (globalThis.manager.aside.index === 0) {
          globalThis.manager.aside.index = childs.length - 1
        } else {
          globalThis.manager.aside.index -= 1
        }
        break;
    }
  }
})
//#endregion
